#ifndef __BSP_CAN_H__
#define __BSP_CAN_H__

#include "can.h"
#include "gpio.h"

// 主频Pclk 与 波特率定义

#define CAN_CHIP_TJA1043

#define CAN_CONFIG_48MHZ_500K

#define EVB_CAN_RX_PORT     GpioPortB
#define EVB_CAN_RX_PIN      GpioPin8

#define EVB_CAN_TX_PORT     GpioPortB
#define EVB_CAN_TX_PIN      GpioPin9

#define EVB_CAN_STB_PORT    GpioPortA
#define EVB_CAN_STB_PIN     GpioPin3 /*IO_STB*/

#define CAN_ID_BACKLIGHT  0X3b3  /*背光*/

#define CAN_ID_ACC  0X263   /* ACC */

#define CAN_ID_GAIN  0X445   /*电子刹车增益*/

#define CAN_ID_KEEPALIVE  0X5C0   /*KEEPALIVE*/

#define CAN_ID_BRAKE_X  0X7d  /*脚踩刹车深度*/

#define CAN_ID_BRAKE_SIGNAL  0X242 /*刹车信号*/

typedef struct stc_can
{
	boolean_t RxFlag;
	boolean_t RxFlag_Break; /*接收到刹车深度数据*/
	boolean_t BusErrorFlag;
	boolean_t CANSendFlag;
	boolean_t CAN_keepalive_SendFlag;
	boolean_t brake_signal;
	uint16_t brake_value;
	int Rx_cnt; /* 中断空闲30s倒计时进入低功耗*/
	uint32_t brake_cnt; //刹车长踩8秒
	uint32_t key_cnt; //按键长按计时
}stc_can_t;

typedef enum ACC_Status
{
    Off = 0u,    
    On  = 1u,     	
}en_ACC_Status;

extern stc_can_t APP_CAN;

extern en_ACC_Status ACC_Status;

extern stc_can_txframe_t   TxFrame_Gain;
extern stc_can_txframe_t   TxFrame_Keepalive;

void BSP_Can_Init(void);

void CAN_send_Frame(stc_can_txframe_t *TxFrame, uint8_t frame_len);

void TJA1043_Goto_Sleep(void);

#endif

